<?php
/**
 * 
 * @author tangbl
 *
 */
class ContactusAction extends CommonAction{
	
	
	public function index(){
		if(IS_POST){
			$contact = D("Contact");
			$verify = $this->_param('yzm',"trim","");
			if(empty($verify)||$_SESSION['verify'] != md5(strtoupper($verify))){
				$this->error(L('ctt_form_ele_verificationcode'));
			}
	
			if($contact->create()){
				//发送邮件
				import('ORG.Util.Email');
				$content  = L('ctt_form_ele_username')."：".$contact->username."<br>";
				$content .= L('ctt_form_ele_mobile')."：".$contact->mobile."<br>";
				$content .= L('ctt_form_ele_email')."：".$contact->email."<br>";
				$content .= L('ctt_form_ele_address')."：".$contact->address."<br>";
				$content .= L('ctt_form_ele_message')."：".$contact->message."<br>";
				SendMail("512136344@qq.com",L('ctt_form_ele_comeform'),$content,"admin","info@etackle.com");
				
				$result = $contact->add();
				$this->assign("jumpUrl",U('/Index/index')); 
				$this->success(L('cfg_form_tipmsg_addsucc'));
			}else{
				$this->error($contact->getError());
			}
		}else{
			$this->display();
		}
	}
	
	public function map(){
		$this->display();	
	}
	
}
